Current File : //usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_ntp.cpython-312.pyc
�

 Nh�K��0�UdZddlZddlZddlZddlmZmZddlmZm	Z	m
Z
mZmZddl
mZddlmZddlmZddlmZej*e�ZeZd	Zd
Zgd�Zdd
dgdddd�dedgdddd�dedgdddd�ddgdddd�ddgdddd�d�Zddd�d	gdd�d�dd d!d"�id#did d!d"�d$�d#did#did%�dddd&�idd'diid	ddd(�d)dgddd*�d+d,d-gd-d.d/�d0�d#did d!d"�d$�d-iid#did	dd�d1did2�d#did	dd�d1d id2�d#didd	d&�d d!d"�d2�d#did#did%�d#did	dd�d1d id2�dd'diid3�Zeeefed4<d5D]
Z ed6ee <�d7D]
Z ed8ee <�d9D]
Z ed:ee <�d;eedgd<�Z!eed=<e"gd>��Z#d?�Z$d@efdA�Z%dLdB�Z&dMdC�Z'dD�Z(								dNdE�Z)dF�Z*dGedHedIedJe+d@df
dK�Z,y)OzNTP: enable and configure ntp�N)�Dict�Mapping)�subp�
temp_utils�	templater�
type_utils�util)�Cloud)�Config)�
MetaSchema)�PER_INSTANCEz
/etc/ntp.conf�)�	almalinux�alpine�aosc�
azurelinux�centos�
cloudlinux�cos�debian�	eurolinux�fedora�freebsd�mariner�miraclelinux�openbsd�	openeuler�OpenCloudOS�openmandriva�opensuse�opensuse-microos�opensuse-tumbleweed�
opensuse-leap�photon�rhel�rocky�sle_hpc�	sle-micro�sles�	TencentOS�ubuntu�	virtuozzo�chronydz/etc/chrony.conf�chronyzchrony.conf.{distro})�	check_exe�confpath�packages�service_name�
template_name�template�ntpd�ntpzntp.conf.{distro}�ntpdatez/etc/ntpd.confzntpd.conf.{distro}z/lib/systemd/systemd-timesyncdz-/etc/systemd/timesyncd.conf.d/cloud-init.conf�systemd-timesyncdztimesyncd.conf)r.r6r7�openntpdr8z/etc/chrony/chrony.conf)r0r2)r0r1r2)r.r6z"/usr/lib/systemd/systemd-timesyncdz/etc/systemd/timesyncd.conf)r/r0r2)r.r8)r6r.)r2r0r0)r0r2r3z/usr/local/etc/chrony.conf)r0r1r2r3z/usr/local/sbin/ntpdz/usr/local/etc/ntp.confr9zntpd.conf.openbsd)r/r0r1r2r3)r6r.r9r/)r.r6r8)rrrrrrrrrrr r$r%r)r+�DISTRO_CLIENT_CONFIG)r!r"r#r )rrr&r%)r'r(r)�cc_ntp)�id�distros�	frequency�activate_by_schema_keys�meta)r/r0r1r2c��t}tjt�}||vrtj|||gd��}|S)z�Construct a distro-specific ntp client config dictionary by merging
       distro specific changes into base config.

    @param distro: String providing the distro class name.
    @returns: Dict of distro configurations for ntp clients.
    T��reverse)r:�copy�NTP_CLIENT_CONFIGr	�
mergemanydict)�distro�dcfg�cfgs   �9/usr/lib/python3/dist-packages/cloudinit/config/cc_ntp.py�distro_ntp_client_configsrK
s?�� �D�
�)�)�%�
&�C�
��~�� � �#�t�F�|�!4�d�C���J��returnc�F�t|j�}|r-|dk7r(tjd|�|j	|i�S|jdd�}i}|dk(r�|jD]Q}|j	|�}tj|j	d��s�9tjd|�|}n|s7|jd}tjd|�|j	|i�}|Stjd|�|j	|i�}|S)	a
Determine which ntp client is to be used, consulting the distro
       for its preference.

    @param ntp_client: String name of the ntp client to use.
    @param distro: Distro class instance.
    @returns: Dict of the selected ntp client or {} if none selected.
    �autoz4Selected NTP client "%s" via user-data configuration�
ntp_clientr/z+Selected NTP client "%s", already installedrz<Selected distro preferred NTP client "%s", not yet installedz1Selected NTP client "%s" via distro system config)	rK�name�LOG�debug�get�
get_option�preferred_ntp_clientsr�which)rPrG�
distro_cfg�distro_ntp_client�	clientcfg�clientrIs       rJ�select_ntp_clientr\s%��+�6�;�;�7�J��j�F�*��	�	�B�J�	
��~�~�j�"�-�-��)�)�,��?���I��F�"��2�2�	�F��.�.��(�C��z�z�#�'�'�+�.�/��	�	�A�6�� �	��	���1�1�!�4�F��I�I�N��
�#���v�r�2�I���
	�	�	�?��	
��N�N�#4�b�9�	��rLc�J�tj|�ry|�dg}||�y)ahInstall ntp client package if not already installed.

    @param install_func: function.  This parameter is invoked with the contents
    of the packages parameter.
    @param packages: list.  This parameter defaults to ['ntp'].
    @param check_exe: string.  The name of a binary that indicates the package
    the specified package is already installed.
    Nr6)rrW)�install_funcr1r/s   rJ�install_ntp_clientr_Ms(���z�z�)������7����rLc�v�tjj|�rtj||dz�yy)z�Rename any existing ntp client config file

    @param confpath: string. Specify a path to an existing ntp client
    configuration file.
    z.distN)�os�path�existsr	�rename�r0s rJ�rename_ntp_confrf^s,��
�w�w�~�~�h�����H�h��0�1� rLc	���g}|}|dk(rd}n|dk(s|dk(rd}tt�D]E}|jdjt	|�g|gzdgzD�cgc]}|s�|��	c}���G|Scc}w)z�Generate a list of server names to populate an ntp client configuration
    file.

    @param distro: string.  Specify the distro name
    @returns: list: A list of strings representing ntp servers for this distro.
    r)r rr��.zpool.ntp.org)�range�NR_POOL_SERVERS�append�join�str)rG�names�pool_distro�x�ns     rJ�generate_server_namesrshs���
�E��K�
���!��	�8�	�v��4���
�?�
#�
��
����H�H� ��V�H��}�4��7G�G�M�q�1��M�
�	
�
��L��	Ns�A2�A2c	�(�|sg}|sg}|sg}|sg}|s|s|dk(ry|s;|dk(r6|dk(r1t|�}tjddj|��n4|s2|s0t|�}tjddj|��|st	d��|s
|st	d	��||||d
�}	|r3tjdd�
�}
|
d}tj||��tj|||	�|rtj|�yy)a�Render a ntp client configuration for the specified client.

    @param distro_name: string.  The distro class name.
    @param service_name: string. The name of the NTP client service.
    @param servers: A list of strings specifying ntp servers. Defaults to empty
    list.
    @param pools: A list of strings specifying ntp pools. Defaults to empty
    list.
    @param allow: A list of strings specifying a network/CIDR. Defaults to
    empty list.
    @param peers: A list nodes that should peer with each other. Defaults to
    empty list.
    @param path: A string to specify where to write the rendered template.
    @param template_fn: A string to specify the template source file.
    @param template: A string specifying the contents of the template. This
    content will be written to a temporary file before being used to render
    the configuration file.

    @raises: ValueError when path is None.
    @raises: ValueError when template_fn is None and template is None.
    rNrr5z%Adding distro default ntp servers: %s�,z*Adding distro default ntp pool servers: %sz Invalid value for path parameterz$Not template_fn or template provided)�servers�pools�allow�peersztemplate_name-z.tmpl)�prefix�suffix�)�content)rsrRrSrm�
ValueErrorr�mkstempr	�
write_filer�render_to_file�del_file)�distro_namer2rvrwrxryrb�template_fnr4�params�tfiles           rJ�write_ntp_config_templater��s��@�������������5�[�E�%9���{�h�.�<�6�3I�(��4���	�	�9�3�8�8�G�;L�M���%�k�2���	�	�8�#�(�(�5�/�	
���;�<�<��x��?�@�@�����	�F���"�"�*:�7�K���A�h������X�6�
���[�$��7���
�
�k�"�rLc���g}tjt|j���}|r<dj	t|��}|j
dj|���n<t|jd�|jd�g�s|j
d�t|j��D]�\}}d|z}|dk(r?t|t|t�g�r�,|j
d	j||�
���O|dk(r4t|t�r�e|j
dj||�
����|d
vr7|���t|t�r��|j
dj||�
����t|t�r��|j
dj||�
����|r*tdjdj	|�����y)aOValidate user-provided ntp:config option values.

    This function supplements flexible jsonschema validation with specific
    value checks to aid in triage of invalid user-provided configuration.

    @param ntp_config: Dictionary of configuration value under 'ntp'.

    @raises: ValueError describing invalid values provided.
    z, z(Missing required ntp:config keys: {keys})�keysr4r3zJEither ntp:config:template or ntp:config:template_name values are requiredzntp:config:r0z6Expected a config file path {keypath}. Found ({value}))�keypath�valuer1zHExpected a list of required package names for {keypath}. Found ({value}))r4r3Nz5Expected a string type for {keypath}. Found ({value})z$Invalid ntp configuration:\n{errors}�
)�errors)�REQUIRED_NTP_CONFIG_KEYS�
difference�setr�rm�sortedrl�format�anyrT�items�all�
isinstancern�listr~)�
ntp_configr��missingr��keyr�r�s       rJ�supplemental_schema_validationr��s����F�&�1�1�#�j�o�o�6G�2H�I�G���y�y����)���
�
�6�=�=�4�=�H�	
��	���
�	#�Z�^�^�O�%D�E��	�
�
�
�	
��Z�-�-�/�0��
��U��#�%���*����z�%��5�6�7��
�
�'�'-�v�g�U�v�'K���J�
��e�T�*��
�
�'�'-�v�g�U�v�'K���1�
1��}���e�S�)��
�
�'�'-�v�g�U�v�'K���E�3�'��M�M�G�N�N�#�5�O��
�/�:��3�:�:��y�y��(�
;�
�
�	
�rLrQrI�cloud�argsc
��d|vrtjd|�y|d}|�i}t|t�s.t	djt
j|�����|jdd�}tj|�rtjd|�yt|jd	�|j�}tj||jd
i�gd��}t|�t|jd��
�d}|jd�s[|dj!d|jj"�}|j%|�}|sd|jd�z}	t	|	��tjd|jd��tjd|jdg��tjd|jdg��tjd|jdg��tjd|jdg��t'|jj"|jd�|jdg�|jdg�|jdg�|jdg�|jd�||jd���	t)|jj*|d|d��tj,�rn|jd�d k7r:	|jj/d!d �	|jj/d#d �	|jj/d%|d�	|jj/d'|d�y#t0j2$rtj5d"�Y��wxYw#t0j2$rtj5d$�Y��wxYw#t0j2$r}
tj7d&|
��d}
~
wwxYw#t0j2$r}
tj7d(|
��d}
~
wwxYw))zEnable and configure ntp.r6z8Skipping module named %s, not present or disabled by cfgNzL'ntp' key existed in config, but not a dictionary type, is a {_type} instead)�_type�enabledTz)Skipping module named %s, disabled by cfgrP�configrBr0rer4r3z{distro}z#No template found, not rendering %szservice_name: %sr2zservers: %srvz	pools: %srwz	allow: %srxz	peers: %sry)r2rvrwrxryrbr�r4r1r/)r1r/r5�stopz Failed to stop base ntpd service�disablez#Failed to disable base ntpd service�enablez Failed to enable ntp service: %s�reloadz&Failed to reload/start ntp service: %s)rRrSr��dict�RuntimeErrorr�r�obj_namerTr	�is_falser\rGrFr�rf�replacerQ�get_template_filenamer�r_�install_packages�is_BSD�manage_servicer�ProcessExecutionError�warning�	exception)rQrIr�r��ntp_cfgr��ntp_client_configr�r3�msg�es           rJ�handler�s����C���	�	�F��	
�	��%�j�G������g��&��
$�$*�F��1D�1D�W�1M�F�$N�
�	
��k�k�)�T�*�G��}�}�W���	�	�=�t�D��*����L�!�5�<�<����*�*�	�G�K�K��"�5�6����#�#4�5��.�2�2�:�>�?��K�� � ��,�)�/�:�B�B�����)�)�
�
��1�1�-�@���5�#�'�'��8�9�
��s�#�#��I�I� �"3�"7�"7��"G�H��I�I�m�W�[�[��B�7�8��I�I�k�7�;�;�w��3�4��I�I�k�7�;�;�w��3�4��I�I�k�7�;�;�w��3�4��
�����&�*�*�>�:����I�r�*��k�k�'�2�&��k�k�'�2�&��k�k�'�2�&�
�
"�
"�:�
.��"�&�&�z�2�
��
���%�%�"�:�.�#�K�0��
�{�{�}�� � ��0�F�:�
@����+�+�F�F�;�
C����+�+�I�v�>�	��L�L�'�'��+�N�;�
��
���#�#��'��7�	
���-�-�
@����>�?�
@���-�-�
C����A�B�
C���)�)�	��M�M�<�a�@���	���%�%���
�
�>��B�
���sT�&N �O� O<�P.� (O�
O�(O9�8O9�<P+�P&�&P+�.Q�Q�Q)Nr5)N)NNNNNNNN)-�__doc__rD�loggingra�typingrr�	cloudinitrrrrr	�cloudinit.cloudr
�cloudinit.configr�cloudinit.config.schemar�cloudinit.settingsr
�	getLogger�__name__rRr>�NTP_CONFrkr=rEr:rn�__annotations__rGr@�	frozensetr�rKr\r_rfrsr�r�r�r��rLrJ�<module>r�s���$���	� �C�C�!�#�.�+��g����!���	�������F�&��J� �/��
����G��,��
����K�!�,��
��$���-��
�6�C��+�)��
�C)��^2�%�
�
(��"�
�
�	�=�5�
�
�
�I�
�>�5�
�	�
�F�
�
�I�
�	�	�%�1�
��	��1�
��(�"�0�
�5�!�
�%�3�	
�0�1�#��&�0�
��,
�I�
�>�5�
�	�	�B��

�I�
�(�"�
�

�9�
��
�I�
�(�"�
�

�=�
��
�I�
�!'�O�D�=�5�
�	�
�F�
�
�I�
�	
�
�I�
�(�"�
�

�=�
�
�	��1�
��II)��d�3��9�o�I�VK�D�F�#7�
�#C��� �D�3�@�F�#7��#?��� �@�'�@�F�#7��#?��� �@���� %�w�	��j��%�9���
�/�W�/�d�"2��>��
�
�
�	
��
�J#�Z:
�z_��_�6�_�%�_�t�_��_rL
Page Not Found
Parece que el enlace que apuntaba aquí no sirve. ¿Quieres probar con una búsqueda?
¡Hola!